/* GUI CONVERTED from rwrorp01.p (converter v1.76) Mon Sep 17 22:18:44 2001 */
/* rwrorp01.p - ROUTING CODE COST REPORT                                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.8.1.4 $                                                   */
/*V8:ConvertMode=FullGUIReport                                          */
/* REVISION: 1.0      LAST MODIFIED: 01/12/87   BY: EMB                 */
/* REVISION: 1.0      LAST MODIFIED: 08/29/86   BY: EMB *12*            */
/* REVISION: 1.0      LAST MODIFIED: 09/02/87   BY: WUG *A94 *          */
/* REVISION: 4.0      LAST MODIFIED: 03/18/88   BY: EMB *A171*          */
/* REVISION: 4.0      LAST MODIFIED: 02/24/88   BY: WUG *A175*          */
/* REVISION: 4.0      LAST MODIFIED: 01/10/89   BY: flm *A580*          */
/* REVISION: 6.0      LAST MODIFIED: 10/10/90   BY: emb *D086*          */
/* REVISION: 6.0      LAST MODIFIED: 11/05/90   BY: emb *D175*          */
/* REVISION: 6.0      LAST MODIFIED: 06/26/91   BY: emb *D736*          */
/* REVISION: 7.0      LAST MODIFIED: 10/30/91   BY: pma *F003*          */
/* REVISION: 7.0      LAST MODIFIED: 10/30/91   BY: pma *F755*          */
/* REVISION: 7.0      LAST MODIFIED: 24/09/93   BY: pxd *GF88*          */
/* REVISION: 7.3      LAST MODIFIED: 12/29/93   BY: ais *FL07*          */
/* REVISION: 7.3      LAST MODIFIED: 11/20/95   BY: bcm *G1DD*          */
/* REVISION: 8.6      LAST MODIFIED: 10/15/97   BY: bvm *K101*          */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb          */
/* Old ECO marker removed, but no ECO header exists *F0PN*              */
/* Revision: 1.8.1.3     BY: Hualin Zhong   DATE: 05/08/01 ECO: *N0YC*  */
/* $Revision: 1.8.1.4 $    BY: Manjusha Inglay  DATE: 08/28/01  ECO: *P01R*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rwrorp01_p_3 "Setup Rate!Labor Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_4 "Total!Burden"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_5 "Setup cost!Unit Run"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_6 "Setup Time!Order Qty"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_7 "Work Ctr!Machine"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_8 "Labor Cost"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_10 "Lbr Bdn %!Mch per Op"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_11 "Lbr Burden!Mch Burden"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_12 "Lbr Bdn Rate!Mch Bdn Rate"
/* MaxLen: Comment: */

&SCOPED-DEFINE rwrorp01_p_13 "As of Date"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable part like ro_routing.
define variable part1 like ro_routing.
define variable wkctr like ro_wkctr.
define variable eff_date like op_date initial today
   label {&rwrorp01_p_13}.
define variable unit_setup
   like sct_lbr_tl format ">>,>>9.99<<<<<".
define variable unit_labor like ro_run.
define variable labor_cost
   like sct_lbr_tl format ">>,>99.999<<<<".
define variable labor_burden like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable mch_bdn_cost like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable total_burden like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable total_labor_cost
   like sct_lbr_tl format ">>,>99.999<<<<".
define variable total_total_burden like sct_bdn_tl
   format ">,>>>,>>9.99<<<<<<<".
define variable total_ro_sub_cost like sct_sub_tl
   format ">,>>>,>>9.99<<<<<<<<".
define variable i as integer.
define variable ord_qty like pt_ord_qty initial 1.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
part     colon 15
   part1          label {t001.i}
   eff_date colon 15
   wkctr    colon 15 skip
   ord_qty  colon 15
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   if part1 = hi_char then part1 = "".

   if c-application-mode <> 'web' then
   
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update &fields = "  part part1  eff_date wkctr
          ord_qty" &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data')) then do:

      bcdparm = "".
      {mfquoter.i part   }
      {mfquoter.i part1  }
      {mfquoter.i eff_date}
      {mfquoter.i wkctr  }
      {mfquoter.i ord_qty}

      if part1 = "" then part1 = hi_char.

   end.

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



   {mfphead.i}

   for each ro_det where (ro_routing >= part and ro_routing <= part1)
         and (eff_date = ? or ((ro_start = ? or ro_start <= eff_date)
         and (ro_end = ? or ro_end >= eff_date)))
         and (ro_wkctr = wkctr or wkctr = "")
         no-lock break by ro_routing by ro_op with frame b:

      FORM /*GUI*/ 
         space(9)
         ro_wkctr     column-label {&rwrorp01_p_7}
         ro_setup     column-label {&rwrorp01_p_6}
         unit_setup   column-label {&rwrorp01_p_5}
         unit_labor   column-label {&rwrorp01_p_3}
         labor_cost   column-label {&rwrorp01_p_8}
         wc_bdn_pct   column-label {&rwrorp01_p_10}
         wc_bdn_rate  column-label {&rwrorp01_p_12}
         labor_burden column-label {&rwrorp01_p_11}
         total_burden column-label {&rwrorp01_p_4}
         ro_sub_cost
         format ">,>>>,>>9.99<<<<<<<<"
      with STREAM-IO /*GUI*/  frame b width 132 no-attr-space.

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).

      if first-of(ro_routing) then do:
         if page-size - line-counter < 4 then page.
         assign
            total_labor_cost = 0
            total_total_burden = 0
            total_ro_sub_cost = 0.

         display with frame b STREAM-IO /*GUI*/ .

         put getTermLabelRtColon("ROUTING",8) to 8 space(1) ro_routing.
      end.

      find wc_mstr where wc_wkctr = ro_wkctr
         and wc_mch = ro_mch
         no-lock no-error.
      if available wc_mstr then do:
         unit_setup = ro_setup.
         if ord_qty <> 0
            then unit_setup = ro_setup / ord_qty.

         assign
            unit_labor = unit_setup + ro_run
            labor_cost = (ro_run * wc_lbr_rate) +
               ((ro_setup * wc_setup_rte) / ord_qty).

         /*! CALCULATE OPERATION LABOR BURDEN USING THE STANDARD     *
         *  EQUATION.                                               */
         {gprun.i ""rwbdncal.p""
            "( input 'LABOR'              /* BURDEN COST TYPE */,
               input no                  /* ACCUMULATE TOTAL? */,
               input (wc_bdn_pc * 0.01)     /* BURDEN PERCENT */,
               input wc_bdn_rate               /* BURDEN RATE */,
               input wc_lbr_rate                /* LABOR RATE */,
               input 0                 /* MACHINE BURDEN RATE */,
               input 0                       /* MACHINES USED */,
               input ord_qty                /* ORDER QUANTITY */,
               input ro_run                  /* UNIT RUN TIME */,
               input wc_setup_rte               /* SETUP RATE */,
               input ro_setup                   /* SETUP TIME */,
               input 1                       /* YIELD PERCENT */,
               input-output labor_burden       /* BURDEN COST */
                )"
            }

         /*! CALCULATE OPERATION MACHINE BURDEN USING THE STANDARD   *
         *  EQUATION.                                               */
         {gprun.i ""rwbdncal.p""
            "( input 'MACHINE'            /* BURDEN COST TYPE */,
               input no                  /* ACCUMULATE TOTAL? */,
               input 0                      /* BURDEN PERCENT */,
               input 0                         /* BURDEN RATE */,
               input 0                          /* LABOR RATE */,
               input wc_mch_bdn        /* MACHINE BURDEN RATE */,
               input ro_mch_op               /* MACHINES USED */,
               input ord_qty                /* ORDER QUANTITY */,
               input ro_run                  /* UNIT RUN TIME */,
               input 0                          /* SETUP RATE */,
               input ro_setup                   /* SETUP TIME */,
               input 1                       /* YIELD PERCENT */,
               input-output mch_bdn_cost /* MACHINE BRDN COST */
                )"
            }

         total_burden = labor_burden + mch_bdn_cost.

         if page-size - line-counter < 3 then do:
            page.
            down 1 with frame b.
         end.

         put skip getTermLabelRtColon("OPERATION",8) to 8
                  space(1) string(ro_op) space(1) ro_desc.
         if ro_std_op > "" then
            put space(1)
                {gplblfmt.i &FUNC=getTermLabel(""STANDARD_OPERATION"",8)
                            &CONCAT="':'"}
                space(1) ro_std_op.

         display
            ro_wkctr
            wc_bdn_rate
            wc_bdn_pct
            ro_setup (ro_setup * wc_setup_rte) @ unit_setup
            wc_setup_rte format ">>>,>>9.99" @ unit_labor
            labor_burden WITH STREAM-IO /*GUI*/ .

         down 1.
         display
            ro_mch                            @ ro_wkctr
            ord_qty      format ">,>>>,>>9.9" @ ro_setup
            ro_run                            @ unit_setup
            wc_lbr_rate  format ">>>,>>9.99"  @ unit_labor
            mch_bdn_cost                      @ labor_burden
            ro_mch_op    format ">>>>>"       @ wc_bdn_pct
            wc_mch_bdn                        @ wc_bdn_rate
            labor_cost
            total_burden
            ro_sub_cost WITH STREAM-IO /*GUI*/ .
      end. /* if available */

      assign
         total_labor_cost = total_labor_cost + labor_cost
         total_total_burden = total_total_burden + total_burden
         total_ro_sub_cost = total_ro_sub_cost + ro_sub_cost.

      if last-of(ro_routing) then do:
         underline labor_cost total_burden ro_sub_cost.
         display
            total_labor_cost @ labor_cost
            total_total_burden @ total_burden
            total_ro_sub_cost @ ro_sub_cost WITH STREAM-IO /*GUI*/ .
      end.

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end.

   /* REPORT TRAILER  */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" part part1 eff_date wkctr ord_qty "} /*Drive the Report*/
